package com.example.testjpg;

import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class CropActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getSimpleName();

    public final static String IMAGE_PATH = "image_path";
    // Lifecycle Method ////////////////////////////////////////////////////////////////////////////

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_crop);

        if (savedInstanceState == null) {
            String path = getIntent().getStringExtra(IMAGE_PATH);
            getSupportFragmentManager().beginTransaction().add(R.id.container, CropFragment.getInstance(path)).commit();
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }

    /**
     * 裁减成功后回调
     *
     * @param uri
     */
    public void startResultActivity(Uri uri) {
        if (isFinishing()) return;
        // Start ResultActivity
        startActivity(ResultActivity.createIntent(this, uri));
    }

}
